package com.oreilly.ez.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@Entity
@Table(name = "language")
@NoArgsConstructor
@ToString
public class Language {

    @Id
    @GeneratedValue
    private Integer sid;
    private String scode;
    private String note;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    private Date udate = new Date();



    private String sname;


    @ManyToMany
    @JoinTable(name = "rel_user_language",
    joinColumns = @JoinColumn(name = "language_id" ),
    inverseJoinColumns = @JoinColumn(name = "user_id"))
    private List<SysUser> users = new ArrayList<>();
}
